package com.aaa.controller.yy;



import com.aaa.pojo.ResultBean;
import com.aaa.pojo.yy.ViewResultSds;
import com.aaa.service.yy.ViewResultSdsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class ResultSdsController {
    @Autowired
    private ViewResultSdsService resultSdsService;

    ResultBean resultBean = new ResultBean();
    @RequestMapping("/ResultSdsFindAll")
    public ResultBean findAll1(String page, String limit){
        int count = resultSdsService.findCount();
        List<ViewResultSds> all1 = resultSdsService.findAll1(page, limit);
        resultBean.setCode(0);
        resultBean.setMsg("");
        resultBean.setCount(count);
        resultBean.setData(all1);
        return resultBean;
    }
    @RequestMapping("/queryResultSdsById")
    public ResultBean queryResultFdsById(ViewResultSds resultSds){

        ViewResultSds resultSds1 = resultSdsService.queryResultSdsById(resultSds);
        resultBean.setCode(0);
        resultBean.setMsg("");
        resultBean.setCount(1);
        resultBean.setData(resultSds1);
        return resultBean;
    }
    @RequestMapping("/DeleteIdListResultSds")
    public ResultBean deleteIdList(@RequestParam("idList") List<String> idList){
        //System.out.println(idList);
        int i = resultSdsService.deleteIdList(idList);
        resultBean.setCode(0);
        resultBean.setMsg("");
        resultBean.setCount(i);
        resultBean.setData(idList);
        return resultBean;
    }

    @RequestMapping("/fuzzyFindAllResultSds")
    public ResultBean fuzzyFindAll(String name, String testPlanId){
        int count = resultSdsService.findCount();
        List<ViewResultSds> resultSds = resultSdsService.fuzzyFindAll(name, testPlanId);
        resultBean.setCode(0);
        resultBean.setMsg("");
        resultBean.setCount(count);
        resultBean.setData(resultSds);
        return resultBean;
    }
    @RequestMapping("/findAllResultSds")
    public ResultBean findAll(){
        int count = resultSdsService.findCount();
        Map<String, Integer> stringIntegerMap = resultSdsService.findAll();
        resultBean.setCode(0);
        resultBean.setMsg("");
        resultBean.setCount(count);
        resultBean.setData(stringIntegerMap);
        return resultBean;
    }
}
